import {
  Toast
} from "vant";
import cTitle from "components/title";

export default {
  data() {
    return {
      items: {},
      allList: [],
      type: '',
      countPage: '',
      page: 1,
      uid: '',
      date: '', //日期
      minDate: new Date(2020, 0, 1),
      maxDate: new Date(2085, 10, 1),
      currentDate: new Date(),
      pickerShow: false,
    };
  },

  components: {
    cTitle
  },
  
  activated() {
    console.log(this.$route.params, 'teamPerformance')
    this.type = this.$route.params.id;
    this.uid = this.$route.params.uid ? this.$route.params.uid : ''
    this.getData();
  },
  // mounted() {
  //   console.log(this.$route.params, 'teamPerformance')
  //   this.type = this.$route.params.id;
  //   this.uid = this.$route.params.uid ? this.$route.params.uid : ''
  //   this.getData();
  // },
  computed: {

  },
  methods: {
    openPicker() {
      this.pickerShow = true;
    },
    pickerCancel() {
      this.pickerShow = false;
    },
    getData() {
      var uid;
      if (this.type == 1) {
        uid = localStorage.getItem("uid")
      } else {
        uid = this.uid
      }
      this.uid = uid;
      console.log(uid, 'udidididi')
      $http.post("ZhengChengYc.shuju_detail", {
        time: this.date,
        uid: uid,
        type: this.type,
        page: this.page
      }, "加载中").then((res) => {
        if (res.result == 1) {
          console.log(res, 'shuju_detail')
          this.items = res.data;
          this.allList = res.data.date

        }
      });


    },
    toDetail() {
      this.$router.push(this.fun.getUrl("yunPartnerDetails",{uid: this.uid}));
    },
    pickerConfirm(e) {
      console.log(e, '确定')
      const dateString = e;

      // 将字符串转换为Date对象
      const date = new Date(dateString);

      // 提取年、‌月、‌日
      const year = date.getFullYear();
      const month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1; // 月份是从0开始的，‌所以需要+1
      const day = date.getDate();

      // 拼接成年月日格式
      const formattedDate = `${year}-${month}`;
      console.log(formattedDate, 'formattedDate')
      this.date = formattedDate;
      this.pickerShow = false;
      this.getData();
    }
  }
};